package com.ssm.Dao;

import com.ssm.Utils.DBCPUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class chooseTypeDao {

    public List<Object> choose(String type){
        String sql="select * from category where c_type=?";
        Object[] objects={type};
        Object ob1=null;
        List<Object> objectList=new ArrayList<>();
        ResultSet resultSet = DBCPUtils.executeQuery(sql, objects);

        try {
            while (resultSet.next()){
                String c_name=resultSet.getString("c_name");
                String c_place=resultSet.getString("c_place");
                String c_count=resultSet.getString("c_count");
                String c_picture=resultSet.getString("c_picture");

                ob1=new Object[]{c_name, c_count,c_place, c_picture};
                objectList.add(ob1);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            //关闭数据库的方法
            DBCPUtils.closeAll(resultSet, DBCPUtils.pstmt, DBCPUtils.connection);
        }

        return objectList;
    }

}
